<?php
	include 'inc.php'; // including connection & basic functions
	$rawsettings = fetch("SELECT * FROM settings;"); // importing settings
	$settings = array(); foreach($rawsettings as $i) $settings[$i[0]] = $i[1]; // easing access
	include 'langs/'.$settings['lang'].'.php'; // importing language
	$classchain = 'top'.$settings['top'].' header'.$settings['header'].' adbar'.$settings['adbar'].' footer'.$settings['footer'];
	if(isset($_COOKIE['id'])) $r = fetch('SELECT * FROM users where id = '.$_COOKIE['id'].' AND pass = "'.$_COOKIE['pass'].'";');
	if(count($r)>0) { include 'panels/createSession.php'; createSession($r[0]); }
?>
<!DOCTYPE html PUBLIC "-//W3C//Ddiv XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/Ddiv/xhtml1-transitional.ddiv">
<html xmlns="http://www.w3.org/1999/xhtml">
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=ISO8859-1" />
		<title><? echo $settings['title']; ?></title>
        <link href='<? echo $rootURL; ?>/search.xml' rel='search' title='<? echo $lang['title']; ?>' type='application/opensearchdescription+xml'/>
		<link href='<? echo $rootURL.'/skins/'.$settings['skin']; ?>/favicon.ico' rel='shortcut icon'/>
		<link href='<? echo $rootURL.'/skins/'.$settings['skin']; ?>/favicon.png' rel='icon'/>
		<link href="skins/<? echo $settings['skin']; ?>/style.css" rel="stylesheet" type="text/css" />
		<script type="text/javascript" src="jquery.js"></script>
		<script type="text/javascript" src="js.js"></script>
	</head>
	<body>
		<div class="topContainer <? echo $classchain; ?>">
			<!-- optional bar on top, similar to blogger navbar -->
			<div class="top">
				<? echo $settings['toptext']; ?>
			</div>
		</div>
		<div class="headerContainer <? echo $classchain; ?>">
			<!-- optional header, customizable via admin panel -->
			<div class="header"></div>
		</div>
		<div class="pageContainer <? echo $classchain; ?>">
			<!-- mandatory page body, containing threads and so -->
			<div class="page">
				<? include 'pages/hot.php'; ?>
			</div>
		</div>
		<div class="adbarContainer <? echo $classchain; ?>">
			<!-- optional sidebar for vertical ad displaying -->
			<div class="adbar"></div>
		</div>
		<div class="panelContainer <? echo $classchain; ?>">
			<!-- mandatory bottom-fixed panel for user operativity -->
			<div class="panel">
				<div class="panelButtons">
					<img class="panelButton browsingButton" src="skins/<? echo $settings['skin']; ?>/browsingButton.gif" onclick="switchToPanel('browsing');" />
					<img class="panelButton threadButton" src="skins/<? echo $settings['skin']; ?>/threadButton.gif" onclick="switchToPanel('thread');"/>
					<img class="panelButton replyButton" src="skins/<? echo $settings['skin']; ?>/replyButton.gif" onclick="switchToPanel('reply');"/>
					<img class="panelButton accountButton" src="skins/<? echo $settings['skin']; ?>/accountButton.gif" onclick="switchToPanel('account');"/>
					<img class="panelButton displayButton" src="skins/<? echo $settings['skin']; ?>/displayButton.gif" onclick="switchToPanel('display');"/>
					<img class="panelButton infoButton" src="skins/<? echo $settings['skin']; ?>/infoButton.gif" onclick="switchToPanel('info');"/>
				</div>
				<div class="panelTitle">Panel title</div>
				<div class="panelSection browsingPanel"><? include 'panels/browsing.php'; ?></div>
				<div class="panelSection threadPanel"><? include 'panels/thread.php'; ?></div>
				<div class="panelSection replyPanel"><? include 'panels/reply.php'; ?></div>
				<div class="panelSection accountPanel"><? include 'panels/account.php'; ?></div>
				<div class="panelSection displayPanel"><? include 'panels/display.php'; ?></div>
				<div class="panelSection infoPanel"><? include 'panels/info.php'; ?></div>
			</div>
		</div>
		<div class="footerContainer <? echo $classchain; ?>">
			<!-- optional bottom-fixed bar, overlapped to panel -->
			<div class="footer">
				<? echo $settings['footertext']; ?>
			</div>
		</div>
    	<div class="wait hide"></div>
		<?
			if(!isset($_SESSION['id'])) { $level = 'anon';
			} elseif ($_SESSION['permission']=='user') { $level = 'user';
			} else { $level = 'mod'; }
			echo '<script type="text/javascript"> setPermission("'.$level.'"); </script>';
		?>
	</body>
</html>